<?php
/* @var $this ShiftChangeController */
/* @var $model ShiftChange */

$this->breadcrumbs=array(
    'Management'=>array('site/management'),
    'Reporting'=>array('site/reporting'),
    'User Schedules Reporting',
);

$this->menu=array(
    //array('label'=>'Create ShiftChange', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $('#shift-change-grid').yiiGridView('update', {
        data: $(this).serialize()
    });
    return false;
});
");
?>

<h1>User Schedule Reporting</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<br>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php 

	
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'id',
	'dataProvider'=>$model->getUserWeekSchedule($model->iduser),
    'filter'=>$model,
	'enableSorting' => false,
	'columns'=>array(		
		array(
			'name'=>'idschedule',
			'header'=>'Username',
			'filter'=>CHtml::listData(User::model()->findAll(array('order'=>'username ASC','condition'=>'team =' . $model->team_id)),
																		 'iduser',
																		 'username'
																		 ),				
			'value'=>'$data->user_relation->username',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),			
		array(
			'name'=>'idweekday',
			'header'=>'Weekday',
			'value'=>'$data->weekday_relation->name',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),			
		array(
			'name'=>'idshift',
			'header'=>'Shift',
			'value'=>'$data->shift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'idqshift',
			'header'=>'Q-Shift',
			'value'=>'$data->qshift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'class'=>'CButtonColumn',
			'header'=>'Change/Swap',
			'template'=>'{view}',
			//'deleteConfirmation'=>'Está seguro de que quiere CANCELAR esta CITA?',
			'buttons'=>array(
						'view'=>array(
									'url'=>'Yii::app()->createUrl("shiftChange/view", array("id"=>$data->changeId))',
									'label'=>'Shift Change',
									'visible'=> '$data->wasChanged',
									'options' => array('style'=>'width:10px;','title'=>'Change Approved. Click for details')
						          ),
						
					   ),			
		),		
	),
)); ?>
